<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>样品管理</title>
    <jsp:include page="/WEB-INF/views/common/link.jsp"/>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <%@include file="/WEB-INF/views/common/navbar.jsp" %>
    <!--菜单回显-->
    <c:set var="currentMenu" value="department"/>
    <%@include file="/WEB-INF/views/common/menu.jsp" %>
    <div class="content-wrapper">
        <section class="content-header">
            <h1>样品编辑</h1>
        </section>
        <section class="content">
            <div class="box">
                <form class="form-horizontal" action="/work/saveOrUpdate" method="post" id="editForm">
                    <input type="hidden" value="${entity.id}" name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-1 control-label">名称：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="name" name="name" value="${entity.name}"
                                   placeholder="请输入姓名">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label class="col-sm-1 control-label">性别：</label>
                        <div class="col-sm-1" style="margin-left: 15px;margin-top: 10px">
                            <input type="radio" name="sex" value="1" ${entity.sex==true?'checked':''}
                                   class="checkbox">男
                        </div>
                        <div class="col-sm-1" style="margin-left: 15px;margin-top: 10px">
                            <input type="radio" name="sex" value="0" ${entity.sex==false?'checked':''}
                                   class="checkbox">女
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="age" class="col-sm-1 control-label">年龄：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="age" name="age" value="${entity.age}"
                                   placeholder="请输入年龄">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="phone_number" class="col-sm-1 control-label">电话号码：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="phone_number" name="phone_number"
                                   value="${entity.phone_number}"
                                   placeholder="请输入电话号码">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="unit" class="col-sm-1 control-label">所属单位：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="unit" name="unit" value="${entity.unit}"
                                   placeholder="请输入所属单位">
                        </div>
                    </div>

                    <div class="form-group " id="role">
                        <label for="role" class="col-sm-1 control-label">所属职务角色：</label><br/>
                        <div class="row" style="margin-top: 10px">
                            <div class="col-sm-2">
                                <select id="my-change-job-select" class="singleSelect" name="job.id" multiple class="form-control allRoles" size="5">
                                    <c:forEach items="${workJobs}" var="workJob">
                                        <option value="${workJob.id}" class="my-change-job" data-age="${workJob.age}"
                                                <c:if test="${workJob.id eq entity.job.id}"> selected </c:if>
                                        >${workJob.name}
                                        </option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                    </div>

                    <%--                    <div class="form-group" style="margin-top: 10px;">--%>
                    <%--                        <label for="job" class="col-sm-1 control-label">所属职务：</label>--%>
                    <%--                        <div class="col-sm-4">--%>
                    <%--                            <input type="text" class="form-control" id="job" name="job" value="${entity.job}"--%>
                    <%--                                   placeholder="请输入所属职务">--%>
                    <%--                        </div>--%>
                    <%--                    </div>--%>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="last_date" class="col-sm-1 control-label">上轮轮岗日期：</label>
                        <div class="col-sm-4">
                            <input id="my-change-date" type="text" class="form-control" id="last_date" name="last_date"
                                   value="${entity.last_date}"
                                   placeholder="请输入上轮轮岗日期(2000-01-01)">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="now_date" class="col-sm-1 control-label">本轮轮岗日期：</label>
                        <div class="col-sm-4">
                            <input id="my-change-date-result" type="text" class="form-control" id="now_date" name="now_date"
                                   value="${entity.now_date}"
                                   placeholder="请输入本轮轮岗日期(2000-01-01)">
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-1 col-sm-6">
                            <button id="submitBtn" type="submit" class="btn btn-primary">保存</button>
                        </div>
                    </div>

                </form>

            </div>

        </section>
    </div>
    <%@include file="/WEB-INF/views/common/footer.jsp" %>
</div>
<script type="text/javascript">

    $(document).ready(function() {
        $('.singleSelect').select2();

        var year;
        var day;
        var middle;

        year = parseInt($("#my-change-date").val().substring(0,4));
        day = parseInt($("#my-change-date").val().substring(8));
        middle = $("#my-change-date").val().substring(4,8)

        $("#my-change-date").blur(function () {
            year = parseInt($("#my-change-date").val().substring(0,4));
            day = parseInt($("#my-change-date").val().substring(8));
            middle = $("#my-change-date").val().substring(4,8)
        })

        $("#my-change-job-select").change(function(){;
            console.log("年限的值为："+parseInt($('#my-change-job-select option:selected').data("age")));
            $("#my-change-date-result").val(year+parseInt($('#my-change-job-select option:selected').data("age"))+middle+day);
        });
    });
</script>

</body>
</html>
